package kr.haggenna.mileage.dao;

import java.util.List;

import kr.haggenna.mileage.domain.Mileage;

import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.stereotype.Component;

@Component
public class MileageDaoImpl extends SqlSessionDaoSupport implements MileageDao{
	
	@Override
	public int getCurrentMileageByMember(String email) {
		int currentMilegae = getSqlSession().selectOne("getCurrentMileageByMember", email);
		return currentMilegae;
	}
	
	@Override
	public List<Mileage> getMileageList() {
		List<Mileage> mileageList = getSqlSession().selectList("getMileageList");
		return mileageList;
	}
	
	@Override
	public void insertMileage(Mileage mileage) {
		getSqlSession().insert("insertMileage",mileage);
	}
	
	@Override
	public List<Mileage> getMileageListByEmail(String email) {
		List<Mileage> list = getSqlSession().selectList("getMileageListByEmail", email);
		return list;
	}
	
	@Override
	public int getInsertMileage(Mileage mileage) {
		int mile_num = getSqlSession().selectOne("getInsertMileage", mileage);
		return mile_num;
	}
	
	@Override
	public Mileage getMileageByNum(int mile_num) {
		Mileage mileage = getSqlSession().selectOne("getMileageByNum", mile_num);
		return mileage;
	}
	
	@Override
	public void updateMileage(Mileage mileage) {
		getSqlSession().update("updateMileage", mileage);
	}
	
	@Override
	public int getMileageCountByAction() {
		int count = getSqlSession().selectOne("getMileageCountByAction");
		return count;
	}
	
}
